/**
 * Copyright (c) 2017-2024 Nop Platform. All rights reserved.
 * Author: canonical_entropy@163.com
 * Blog:   https://www.zhihu.com/people/canonical-entropy
 * Gitee:  https://gitee.com/canonical-entropy/nop-entropy
 * Github: https://github.com/entropy-cloud/nop-entropy
 */
package com.gitee.wsl.func.select.evaluator

import com.gitee.wsl.func.select.IMatchEvaluator

class AndEvaluator<E, C>(
    evaluators: List<IMatchEvaluator<E, C>>
) : AbstractCombiningEvaluator<E, C>(evaluators) {

    override fun matches(node: E, context: C): Boolean {
        for (i in 0..<evaluators.size) {
            val s: IMatchEvaluator<E, C> = evaluators[i]
            if (!s.matches(node, context)) return false
        }
        return true
    }


    override fun toString(): String {
        return evaluators.joinToString( " and ")
    }
}